package Top;

import java.util.HashSet;

/**
 * @author: lwg
 * @Date: 2021/6/17 20:32
 * @Description: 回文字符串和整数反转
 */
public class Solution7 {
    public Boolean reverse(int x) {
        int y = x;
        int res = 0;
        while (x != 0) {
            if (res < Integer.MIN_VALUE / 10 || res > Integer.MAX_VALUE / 10) {
                return false;
            }
            int temp = x % 10;
            x = x / 10;
            res = res * 10 + temp;
        }
        if (res < 0 || res != y) {
            return false;
        }
        return true;
    }

    public static void main(String[] args) {
        Solution7 solution7 = new Solution7();
        System.out.println(solution7.reverse(1221));
    }
}
